#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

class Solution {
public:
    int widthOfBinaryTree(TreeNode* root) {
        vector<pair<TreeNode*, int>> arr;
		arr.push_back({root, root->val});
		int maxN = 0;
		while(!arr.empty()){
			vector<pair<TreeNode*, int>>tmp;
			for(auto &[node, index] : arr){
				if(node->left){
					tmp.push_back({node->left, index * 2});
				}
				if(node->right){
					tmp.push_back({node->right, index * 2 + 1});
				}
			}
			maxN = max(maxN, tmp.back().second - tmp[0].second + 1);
			arr = move(tmp);
		}
		return maxN;
    }
};

int main(){
	
}